#!/bin/sh
trap - INT QUIT TERM

if test -e /run/chronyd.pid; then
	/usr/bin/pkill --pidfile /run/chronyd.pid
else
	echo "missing /run/chronyd.pid" 1>&2
fi

if test -e /var/run/fcron.pid; then
	/usr/bin/pkill --pidfile /var/run/fcron.pid
else
	echo "missing /var/run/fcron.pid" 1>&2
fi

#we used static configuration, hence no dhcp client
#/sbin/dhcpcd --exit

if test -e /var/run/syslog-ng.pid; then
	/usr/bin/pkill --pidfile /var/run/syslog-ng.pid
else
	echo "missing /var/run/syslog-ng.pid" 1>&2
fi

/sbin/udevadm control --exit
/sbin/hwclock --utc --systohc

/bin/sync

if test "$(basename $0)" = "sysreboot"; then
  /sbin/reboot -f
fi

/sbin/poweroff -f
